package level.editor.view.action.frame;

import java.awt.event.ActionEvent;

import level.editor.view.action.DesktopAction;
import level.editor.view.base.BasePanel;
import level.editor.view.base.PanelConstants;
import level.editor.view.desktop.Desktop;
import level.editor.view.group.Group;
import level.editor.view.group.ItemTest;

public class AddPanelAction extends DesktopAction
{

	public AddPanelAction(Desktop desktop, Boolean direction)
	{
		super("Add "
				+ (direction.equals(PanelConstants.LEFT) ? "left" : "right")
				+ " Panel", desktop);
		this.direction = direction;
	}

	@Override
	public void actionPerformed(ActionEvent e)
	{
		if (direction != null)
		{
			if (desktop.getBasePanel() != null)
			{

				BasePanel base = desktop.getBasePanel();
				Group group = new Group();
				group.setSize(300, 300);
				group.add(new ItemTest("button"));
				group.add(new ItemTest("label"));
				group.add(new ItemTest("button"));
				base.addPanel(group, direction);
				desktop.revalidate();
			}
		}
		else
			System.out.println("Error in AddPanelAction");
	}

	private Boolean direction;
}
